Efficient variable-length coding methods, as typified by the Huffman coding method, have been adopted for coding audio signals and video signals. For example, an international standard, ISO/IEC 13818-7, commonly called MPEG-2 AAC (Moving Picture Coding Experts Group-2, Advanced Audio Coding) or the like is renowned as a coding method of audio signals. In this coding method, a plurality of Huffman coding methods are used because their coding efficiency is extremely high.
In the case of AAC, in order to achieve compression of data amount, MDCT (Modified Discrete Cosine Transform) coefficients are scaled and quantized into integers, and then the quantized coefficients are represented as Huffman codes. Here, in the AAC Huffman coding, the Huffman codes are assigned to all the integers, as the representative points for quantization, within a range between the determined maximum and minimum values of the quantized integers. The assignment of the Huffman codes like this means representation of the distance between certain maximum and minimum values, as an Euclidean distance, by equally spaced representative points. As a result, it is possible to control quantization errors only in each space, without fail, regardless of the distribution of the objects to be quantized. In addition, the use of a plurality of Huffman codebooks of various quantization resolutions gives the choice between less bit consumption for more quantization errors and more bit consumption for less quantization errors.
FIG. 1 is a diagram showing a configuration of a coding apparatus 100 for coding audio signals by the conventional AAC method. The coding apparatus 100 includes a scaling unit 101, a quantization unit 102, a code generation unit 103, a codebook holding unit 104 and a stream generation unit 105. A digital audio signal in the time domain obtained by sampling an analog audio signal at a fixed frequency is split, at a regular time interval, into groups of a fixed number of samples, transformed via MDCT into MDCT coefficients that are data in the frequency domain, and then inputted, as an input digital signal Y, into the coding apparatus 100. The input digital signal Y is inputted to the scaling unit 101, which scales the MDCT coefficients included in each frequency band called a scale factor band, with one certain gain A for each scale factor band. The scaling unit 101 outputs the scaling gain A to the stream generation unit 105, and outputs the MDCT coefficients X obtained as a result of the scaling to the quantization unit 102. The quantization unit 102 quantizes the scaled MDCT coefficients X using a predetermined conversion formula. To be more specific, in the case of the AAC method, rounding off the MDCT coefficient which is expressed as a floating point into an integer value is the quantization thereof. The code generation unit 103 codes the quantized MDCT coefficients with reference to a codebook stored in the codebook holding unit 104, and outputs the codes C thereof to the stream generation unit 105. The stream generation unit 105 adds header information and the like to the gain A inputted from the scaling unit 101 and the codes C within the scale factor band inputted from the code generation unit 103, and outputs them as a stream. In the codebook holding unit 104, a plurality of codebooks of various quantization resolutions are stored. If coding is performed with reference to the codebook of lower quantization resolution, among the codebooks stored in the codebook holding unit 104, the bit amount of the stream can be reduced in return for more quantization errors. On the contrary, if coding is performed with reference to the codebook of higher quantization resolution, the quantization errors can be reduced in return for more bit amount of the stream. In sum, the coding apparatus 100 enhances the coding efficiency by selecting the codebook suitable for the coding from among the codebooks of various quantization resolutions.
FIG. 2 is a diagram showing an example of codebooks 201 to 204 of various quantization resolutions stored in the codebook holding unit 104 of the conventional coding apparatus 100 as shown in FIG. 1. In the codebook 201, quantized values can be any of the integers “−1”, “0” and “1” between the maximum value “1” and the minimum value “−1”, and the codes for the quantized values are represented as binary values using 0 and 1. In the codebook 202, quantized values can be any of the integers “−2”, “−1”, “0”, “1” and “2” between the maximum value “2” and the minimum value “−2”, and the codes for the quantized values are represented as binary values using 0 and 1. In the codebook 203, quantized values can be any of the integers “−3”, “−2”, “−1”, “0”, “1”, “2” and “3” between the maximum value “3” and the minimum value “−3”, and the codes for the quantized values are represented as binary values using 0 and 1. In the codebook 204, quantized values can be any of the integers “−4”, “−3”, “−2”, “−1”, “0”, “1”, “2”, “3” and “4” between the maximum value “4” and the minimum value “−4”, and the codes for the quantized values are represented as binary values using 0 and 1. These codes are just examples, and the present invention is not limited to them.
FIG. 3 shows distributions of representative points (quantized values X′) for quantization of objects to be quantized X with reference to each of the codebooks in FIG. 2, namely, sets of integers that are representative points. As shown in FIG. 2 and FIG. 3, the codebook 201 shows that the codes are assigned to three representative points “1”, “0” and “−1”. In this case, the MDCT coefficients that are the objects to be quantized X1 are scaled so as to be values around between the maximum value “1” and the minimum value “−1” (but not limited to those values). As mentioned above, the codes require only three values for representing respective representative points in the case where coding is performed with reference to the codebook 201, so only a small number of bits are needed. The codebook 202 shows that the codes are assigned to five representative points “2”, “1”, “0”, “−1” and “−2” as quantized values X2′. In this case, the MDCT coefficients that are the objects to be quantized X2 are scaled so as to be values around between the maximum value “2” and the minimum value “−2” (but not limited to those values). As mentioned above, in the case where coding is performed with reference to the codebook 202, the codes of a larger number of bits are needed for representing five quantized values X2′ than the case where three quantized values X1′ are represented in the codebook 201. Similarly, in the case where coding is performed with reference to the codebook 203, the codes are assigned to seven quantized values X3′ from “−3” to “+3”, and the MDCT coefficients that are the objects to be quantized X3 are scaled so as to be values around between the maximum value “3” and the minimum value “−3”. In the case where coding is performed with reference to the codebook 204, the codes are assigned to nine quantized values X4′ from “−4” to “+4”, and the MDCT coefficients that are the objects to be quantized X4 are scaled so as to be values around between the maximum value “4” and the minimum value “−4”. In the case of the AAC as an audio coding method, quantization and coding are performed using the method as mentioned above.
In addition, as shown in FIG. 2, the codebooks 201 to 204 are designed so that the codes of shorter bit patterns are assigned to frequently appearing quantized values.
However, in the conventional method, the objects to be quantized are just quantized into representative points which are equally spaced in both plus and minus directions from 0 as a center, regardless of the actual distribution of the objects. For example, as is obvious from FIG. 3, the representative points 301 to 304 that correspond to the codebooks 201 to 204 are distributed at equal spaces in the plus and minus directions from 0 as a center. It is statistically common that the objects to be quantized are distributed at equal spaces, but it is rather difficult to say that they are always equally spaced from 0 as a center and never be biased toward either plus or minus direction.
Furthermore, in the above conventional method, objects to be quantized are quantized using a plurality of Huffman codebooks of various quantization resolutions for improvement of coding efficiency. However, when a codebook is switched into another codebook of another quantization resolution, the objects to be quantized need to be rescaled for adopting them to the resolution of the other codebook. FIG. 4 is a flowchart showing an example of the procedures of the coding processing in the case where the conventional coding apparatus 100 performs coding using codebooks of various quantization resolutions. Here, the case where coding is performed first with reference to the codebook of the highest quantization resolution will be explained as an example of the coding method. It is assumed, in this case, that coding is performed with reference to a codebook of the one-level lower quantization resolution when the number of bits in a scale factor band exceeds a reference value as a result of the coding using the codebook of the highest quantization resolution, and then such coding is repeated until the number of bits in the scale factor band becomes the reference value or less or there is no more codebooks of the lower quantization resolution. First, “N” number of (where N is a natural number) MDCT coefficients (y1, y2, y3, . . . , yN) in each scale factor band are inputted into the scaling unit 101 (S401). The scaling unit 101 scales the inputted MDCT coefficients so that the values thereof fall within a range of representative points in the codebook of the highest quantization resolution (S402). For example, in the case where coding is performed with reference to the codebook 204, the scaling unit 101 scales the “k”th MDCT coefficients yk with a gain A when an equation −4<(yk/A)=xk<+4 holds for all these MDCT coefficients, where k=1, 2, . . . , n. The quantization unit 102 rounds off the scaled MDCT coefficients xk, and the code generation unit 103 reads out, from the codebook 204, the codes Ck which are to be assigned to the quantized values xk′ obtained by the rounding-off. The code generation unit 103 calculates the total number of bits of N codes (C1, C2, C3, . . . , CN) in the scale factor band (S403), and judges whether or not the calculated total number of bits is the target number of bits or less (S404).
When the total number of bits of the codes in the scale factor band is the target number of bits or less in Step S404 (YES in S404), the code generation unit 103 outputs, to the stream generation unit 105, the ID (or the number or the like) of the codebook used for coding the scale factor band and the codes (C1, C2, C3, . . . , CN) in the scale factor band. The stream generation unit 105 outputs a stream including: the ID of the codebook and the codes (C1, C2, C3, . . . , CN) in the scale factor band which are outputted from the code generation unit 103; and the scaling gain A which is outputted from the scaling unit 101 (S405). The MDCT coefficients in the next scale factor band are inputted to the coding apparatus 100, which starts the above-mentioned processing from Step S401.
When the total number of bits of the N codes (C1, C2, C3, . . . , CN) in the scale factor band is larger than the target number of bits in Step S404 (NO in S404), the code generation unit 103 instructs the scaling unit 101 to rescale the MDCT coefficients (y1, y2, y3, . . . , yN) in the same scale factor band so that the values thereof fall within a range of values of representative points in the codebook of the one-level lower quantization resolution. According to this instruction, the scaling unit 101 returns to the processing in Step S402 and rescales the coefficients (S402). To be more specific, for the purpose of coding with reference to the codebook 203 of the one-level lower quantization resolution than the codebook 204, the scaling unit 101 scales the “k”th MDCT coefficients yk with a gain A when an equation −3<(yk/A)=xk<+3 holds for all these MDCT coefficients, where k=1, 2, . . . , n. The quantization unit 102 rounds off the scaled MDCT coefficients xk, and the code generation unit 103 reads out, from the codebook 203, the codes Ck which are to be assigned to the quantized values xk′ obtained by the rounding-off. The code generation unit 103 calculates the total number of bits of N codes (C1, C2, C3, . . . , CN) in the scale factor band (S403), and judges whether or not the calculated total number of bits is the target number of bits or less (S404). In the case where the total number of bits of the N codes (C1, C2, C3, . . . , CN) in the scale factor band is still larger than the target number of bits at this time, the coding apparatus 100 returns to the processing in Step S402, modifies the value of the gain A, and repeats the processing in Steps S402 to S404 until there is no more codebooks of the lower quantization resolution or the total number of bits in the scale factor band becomes the target number of bits or less.
As described above, for the sake of rescaling, not only division needs to be carried out for N number of MDCT coefficients included in each scale factor band, but also each of the real number values of the N number of MDCT coefficients needs to be compared with a range of values of representative points. These division and comparison require an enormous amount of calculations, which causes a problem in coding.
Against the backdrop as mentioned above, an object of the present invention is to provide a coding apparatus that allow more efficient coding without increase in processing load due to resealing and a decoding apparatus.